export default {
	methods: {
		handleDiagnoseDescArr(val) {

			var diagnoseDescArr = val.diagnoseDesc.split("|");
			var arrSize = diagnoseDescArr.length;
			for (var i = 0; i < arrSize; i++) {
				diagnoseDescArr[i] = (diagnoseDescArr[i] + "").replace('亮点', '<span style="font-size: 20px; color:white; font-weight:bolder;">亮点</span>')
					.replace('不足', '<span style="font-size: 20px; color:white; font-weight:bolder;">不足</span>')
					.replace('建议', '<span style="font-size: 20px; color:white; font-weight:bolder;">建议</span>');
			}
			return diagnoseDescArr;
		},

		// 处理未解锁状态的文本显示行
		handleUnpayedContent(content){
			var result = [];
			var lineWeight = 17; //每行限制的字符权重数量
			var textContent = content+"";
			var tempWeight = 0.0;
			var tempString = "";
			var currentLineNum =0;
			for(var i=0;i<textContent.length; i++){
				var oneChar =  textContent.charAt(i)+"";
				if("\n" == oneChar){
				   	if(i-1<textContent.length){
						if(textContent.charAt(i-1)+"" == "\n"){
                            continue;      
						} 
					}
				}
				if (/.*[\u4e00-\u9fa5]+.*$/.test(oneChar)) {
					// 是中文
					tempWeight += 1.0;
				} else if (/.*[A-Z]+.*$/.test(oneChar)) {
					tempWeight += 1.0;
				} else if (/.*[a-z]+.*$/.test(oneChar)) {
					tempWeight += 0.4;
				} else if (/.*[0-9]+.*$/.test(oneChar)) {
					tempWeight += 0.5;
				} else if("\n" == oneChar){

				} else{
					tempWeight += 1;
				}
				tempString += oneChar;
                if(tempWeight>=lineWeight || i==textContent.length-1 || "\n" == oneChar){
					result[currentLineNum] = tempString;
					tempString = "";
					tempWeight = 0;
					currentLineNum += 1;
				}
			}

			return result;
		},

		handleContentList(sourceList) {
			var contentList = [];
			var limitLineCount = 12; //每一页限制的行数
			var lineCharNum = 17; //每行限制的字符权重数量

			var allLineCount = 0;
			var currentIndex = 0;
			var currentBox = 0;
			for (var index = 0; index < sourceList.length; index++) {
				var element =  sourceList[index];
				//var elementArr = element.split("");
				var elementLength = element.length;
				var tempCharNum = 2.0;
				var tempString = "&emsp;&emsp;";
				for (var i = 0; i < elementLength; i++) {
					var oneChar = element.charAt(i) + "";
					if (/.*[\u4e00-\u9fa5]+.*$/.test(oneChar)) {
						// 是中文
						tempCharNum += 1.0;
					} else if (/.*[A-Z]+.*$/.test(oneChar)) {
						tempCharNum += 1.0;
					} else if (/.*[a-z]+.*$/.test(oneChar)) {
						tempCharNum += 0.4;
					} else if (/.*[0-9]+.*$/.test(oneChar)) {
						tempCharNum += 0.5;
					} else {
						tempCharNum += 1;
					}

					tempString += oneChar;
					if (tempCharNum >= lineCharNum || i == elementLength - 1) {
						let currentPage = Math.floor(
							allLineCount / limitLineCount
						);
						let currentLine = Math.floor(
							allLineCount % limitLineCount
						);
						if (currentLine == 0) {
							currentBox = 0;
							contentList[currentPage] = [];
							contentList[currentPage][currentBox] = [];
						}
						contentList[currentPage][currentBox][currentIndex] =
							tempString;
						tempString = "";
						tempCharNum = 0;
						allLineCount += 1;

						currentIndex += 1;
						if (i == elementLength - 1) {
							// 段落换行
							if (currentLine + 1 < limitLineCount) {
								contentList[currentPage][currentBox + 1] = [];
							}
							currentBox += 1;
							currentIndex = 0;
						}
					}
				}
			}

			return contentList;
		},

		parseDiagnosisResumeContent(val){
			var list = (val.diagnoseContent+"").split("\n\n");  
			return this.handleContentList(list);
		},
	 
	}
}